﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for cls_tbQuyen_Muc_Nut_Detail
/// </summary>
public class cls_tbQuyen_Muc_Nut_Detail
{
	public cls_tbQuyen_Muc_Nut_Detail()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static string InsertUpdate(string Nut_Id, string Muc_Id, int F_STTQUYEN, bool Nut_Enabled)
    {
        av.dal.SqlDataProvider clsSQL = new av.dal.SqlDataProvider();
        object[] myValue = { Nut_Id, Muc_Id, F_STTQUYEN, Nut_Enabled };
        string[] myPara = { "@Nut_Id", "@Muc_Id", "@F_STTQUYEN", "@Nut_Enabled" };
        SqlParameter[] Parameter = new SqlParameter[myPara.Length];
        for (int i = 0; i < myPara.Length; i++)
        {
            Parameter[i] = new SqlParameter(myPara[i], myValue[i]);
        }
        try
        {
            if (clsSQL.ExecuteNonQuery("tbQuyen_Muc_Nut_Detail_InsertUpdate", CommandType.StoredProcedure, Parameter) > 0)
            {
                return "OK";
            }
            else
            {
                return "NO";
            }
        }
        catch (SqlException ex) { return ex.Message; }
    }
    public static DataTable Get(string Muc_Id, int F_STTQUYEN, string Nut_Id)
    {
        DataTable table = new DataTable();
        av.dal.SqlDataProvider clsSQL = new av.dal.SqlDataProvider();
        SqlParameter[] parameter = new SqlParameter[3];
        parameter[0] = new SqlParameter("@Muc_Id", Muc_Id);
        parameter[1] = new SqlParameter("@F_STTQUYEN", F_STTQUYEN);
        parameter[2] = new SqlParameter("@Nut_Id", Nut_Id);
        
        try
        {
            table = clsSQL.GetDataFrom("tbQuyen_Muc_Nut_Detail_Get", CommandType.StoredProcedure, parameter);

        }
        catch { }
        return table;
    }
    public static bool SeeButton(string Muc_Id, int F_STTQUYEN, string Nut_Id)
    {
        bool rs = false;
        DataTable dt = new DataTable();
        dt = Get(Muc_Id, F_STTQUYEN, Nut_Id);
        if (dt.Rows.Count == 1)
        {
            rs = true;
        }
        return rs;
    }
}